Micron Document
🎖️GitЯра🎖️

Node / meshtastic / Meshtastic-Android / files / core / ui / src / commonMain / kotlin / org / meshtastic / core / ui / component / TracerouteAlertHandler.kt

Displaying Raw • Download

core/ui/src/commonMain/kotlin/org/meshtastic/core/ui/component/TracerouteAlertHandler.kt 2d20cd8a4708e2ef66e98d5259f3a97ec93f240a (2d20cd8a) Text, 5.12 KB

T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.ui.component

Tff7b72import T7ee787androidx.compose.foundation.layout.Column
Tff7b72import T7ee787androidx.compose.foundation.rememberScrollState
Tff7b72import T7ee787androidx.compose.foundation.verticalScroll
Tff7b72import T7ee787androidx.compose.material3.MaterialTheme
Tff7b72import T7ee787androidx.compose.material3.Text
Tff7b72import T7ee787androidx.compose.runtime.Composable
Tff7b72import T7ee787androidx.compose.runtime.LaunchedEffect
Tff7b72import T7ee787androidx.compose.runtime.getValue
Tff7b72import T7ee787androidx.compose.runtime.mutableStateOf
Tff7b72import T7ee787androidx.compose.runtime.remember
Tff7b72import T7ee787androidx.compose.runtime.rememberCoroutineScope
Tff7b72import T7ee787androidx.compose.runtime.setValue
Tff7b72import T7ee787androidx.compose.ui.Modifier
Tff7b72import T7ee787androidx.lifecycle.compose.collectAsStateWithLifecycle
Tff7b72import T7ee787co.touchlab.kermit.Logger
Tff7b72import T7ee787kotlinx.coroutines.launch
Tff7b72import T7ee787org.meshtastic.core.resources.Res
Tff7b72import T7ee787org.meshtastic.core.resources.okay
Tff7b72import T7ee787org.meshtastic.core.resources.traceroute
Tff7b72import T7ee787org.meshtastic.core.resources.view_on_map
Tff7b72import T7ee787org.meshtastic.core.ui.theme.StatusColors.StatusGreen
Tff7b72import T7ee787org.meshtastic.core.ui.theme.StatusColors.StatusOrange
Tff7b72import T7ee787org.meshtastic.core.ui.theme.StatusColors.StatusYellow
Tff7b72import T7ee787org.meshtastic.core.ui.util.annotateTraceroute
Tff7b72import T7ee787org.meshtastic.core.ui.util.toMessageRes
Tff7b72import T7ee787org.meshtastic.core.ui.viewmodel.UIViewModel

T8b949e/**
* Handles the display of the traceroute alert when a response is received. Consolidates the side effect logic from the
* main application screens into common code.
*/
Tf0883e@Composable
Tff7b72fun Td2a8ffTracerouteAlertHandlerTb4b4b4(
Te6edf3uiViewModelTb4b4b4: Te6edf3UIViewModelTb4b4b4,
Te6edf3onNavigateToMapTb4b4b4: Tb4b4b4(Te6edf3destinationNodeNumTb4b4b4: Tffa657IntTb4b4b4, Te6edf3requestIdTb4b4b4: Tffa657IntTb4b4b4, Te6edf3logUuidTb4b4b4: Tffa657String?Tb4b4b4) Tff7b72-Tff7b72> Tffa657UnitTb4b4b4,
Tb4b4b4) Tb4b4b4{
Tff7b72val Te6edf3traceRouteResponse Tff7b72by Te6edf3uiViewModelTb4b4b4.Te6edf3tracerouteResponseTb4b4b4.Te6edf3collectAsStateWithLifecycleTb4b4b4(Tff7b72nullTb4b4b4)
Tff7b72var Te6edf3dismissedTracerouteRequestId Tff7b72by Te6edf3remember Tb4b4b4{ Te6edf3mutableStateOfTff7b72<Tffa657Int?Tff7b72>Tb4b4b4(Tff7b72nullTb4b4b4) Tb4b4b4}
Tff7b72val Te6edf3colorScheme Tff7b72= Te6edf3MaterialThemeTb4b4b4.Te6edf3colorScheme
Tff7b72val Te6edf3scope Tff7b72= Te6edf3rememberCoroutineScopeTb4b4b4(Tb4b4b4)

Te6edf3LaunchedEffectTb4b4b4(Te6edf3traceRouteResponseTb4b4b4, Te6edf3dismissedTracerouteRequestIdTb4b4b4) Tb4b4b4{
Tff7b72val Te6edf3response Tff7b72= Te6edf3traceRouteResponse
Tff7b72if Tb4b4b4(Te6edf3response Tff7b72!Tff7b72= Tff7b72null Tff7b72&Tff7b72& Te6edf3responseTb4b4b4.Te6edf3requestId Tff7b72!Tff7b72= Te6edf3dismissedTracerouteRequestIdTb4b4b4) Tb4b4b4{
Te6edf3uiViewModelTb4b4b4.Te6edf3showAlertTb4b4b4(
Te6edf3titleRes Tff7b72= Te6edf3ResTb4b4b4.Te6edf3stringTb4b4b4.Te6edf3tracerouteTb4b4b4,
Te6edf3composableMessage Tff7b72= Tb4b4b4{
Te6edf3ColumnTb4b4b4(Te6edf3modifier Tff7b72= Te6edf3ModifierTb4b4b4.Te6edf3verticalScrollTb4b4b4(Te6edf3rememberScrollStateTb4b4b4(Tb4b4b4)Tb4b4b4)Tb4b4b4) Tb4b4b4{
Te6edf3TextTb4b4b4(
Te6edf3text Tff7b72=
Te6edf3annotateTracerouteTb4b4b4(
Te6edf3responseTb4b4b4.Te6edf3messageTb4b4b4,
Te6edf3statusGreen Tff7b72= Te6edf3colorSchemeTb4b4b4.Te6edf3StatusGreenTb4b4b4,
Te6edf3statusYellow Tff7b72= Te6edf3colorSchemeTb4b4b4.Te6edf3StatusYellowTb4b4b4,
Te6edf3statusOrange Tff7b72= Te6edf3colorSchemeTb4b4b4.Te6edf3StatusOrangeTb4b4b4,
Tb4b4b4)Tb4b4b4,
Tb4b4b4)
Tb4b4b4}
Tb4b4b4}Tb4b4b4,
Te6edf3confirmTextRes Tff7b72= Te6edf3ResTb4b4b4.Te6edf3stringTb4b4b4.Te6edf3view_on_mapTb4b4b4,
Te6edf3onConfirm Tff7b72= Tb4b4b4{
Tff7b72val Te6edf3availability Tff7b72=
Te6edf3uiViewModelTb4b4b4.Te6edf3tracerouteMapAvailabilityTb4b4b4(
Te6edf3forwardRoute Tff7b72= Te6edf3responseTb4b4b4.Te6edf3forwardRouteTb4b4b4,
Te6edf3returnRoute Tff7b72= Te6edf3responseTb4b4b4.Te6edf3returnRouteTb4b4b4,
Tb4b4b4)
Tff7b72val Te6edf3errorRes Tff7b72= Te6edf3availabilityTb4b4b4.Te6edf3toMessageResTb4b4b4(Tb4b4b4)
Tff7b72if Tb4b4b4(Te6edf3errorRes Tff7b72=Tff7b72= Tff7b72nullTb4b4b4) Tb4b4b4{
Te6edf3dismissedTracerouteRequestId Tff7b72= Te6edf3responseTb4b4b4.Te6edf3requestId
Te6edf3onNavigateToMapTb4b4b4(Te6edf3responseTb4b4b4.Te6edf3destinationNodeNumTb4b4b4, Te6edf3responseTb4b4b4.Te6edf3requestIdTb4b4b4, Te6edf3responseTb4b4b4.Te6edf3logUuidTb4b4b4)
Tb4b4b4} Tff7b72else Tb4b4b4{
Te6edf3uiViewModelTb4b4b4.Te6edf3clearTracerouteResponseTb4b4b4(Tb4b4b4)
T8b949e// Post the error alert after the current alert is dismissed to avoid
T8b949e// the wrapping dismissAlert() in AlertManager immediately clearing it.
Tf0883e@SuppressTb4b4b4(Ta5d6ff"Ta5d6ffTooGenericExceptionCaughtTa5d6ff"Tb4b4b4)
Te6edf3scopeTb4b4b4.Te6edf3launch Tb4b4b4{
Tff7b72try Tb4b4b4{
Te6edf3uiViewModelTb4b4b4.Te6edf3showAlertTb4b4b4(Te6edf3titleRes Tff7b72= Te6edf3ResTb4b4b4.Te6edf3stringTb4b4b4.Te6edf3tracerouteTb4b4b4, Te6edf3messageRes Tff7b72= Te6edf3errorResTb4b4b4)
Tb4b4b4} Tff7b72catch Tb4b4b4(Te6edf3eTb4b4b4: Te6edf3ExceptionTb4b4b4) Tb4b4b4{
Te6edf3LoggerTb4b4b4.Te6edf3eTb4b4b4(Te6edf3eTb4b4b4) Tb4b4b4{ Ta5d6ff"Ta5d6ff[TracerouteAlertHandler] Failed to show error alertTa5d6ff" Tb4b4b4}
Tb4b4b4}
Tb4b4b4}
Tb4b4b4}
Tb4b4b4}Tb4b4b4,
Te6edf3dismissTextRes Tff7b72= Te6edf3ResTb4b4b4.Te6edf3stringTb4b4b4.Te6edf3okayTb4b4b4,
Te6edf3onDismiss Tff7b72= Tb4b4b4{
Te6edf3uiViewModelTb4b4b4.Te6edf3clearTracerouteResponseTb4b4b4(Tb4b4b4)
Te6edf3dismissedTracerouteRequestId Tff7b72= Tff7b72null
Tb4b4b4}Tb4b4b4,
Tb4b4b4)
Tb4b4b4}
Tb4b4b4}
Tb4b4b4}

Served by rngit 1.5.0 - Generated in 0.07s